/*
 * © 2010 Autodata Solutions Company. All Rights Reserved
 * This source code is the confidential and proprietary information of Autodata Solutions Company.
 * The user shall not, in whole or in part, copy, publish, disclose or make any use of this source code
 * without the prior written consent of Autodata Solutions Company.
 */
Ext.ns('net.autodata.AbstractView');

(function () {
	
	/**
	 * @class AbstractView
	 * @extends Ext.util.Observable
	 * @namespace net.autodata
	 */
	var AbstractView = Ext.extend(Ext.util.Observable, {
		component: undefined,
		
		/**
		 * NOTE this is an abstract class and cannot be created directly
		 * @method constructor
		 */
		constructor: function ()
		{
			throw 'AbstractView cannot be created directly';
		},
		
		/**
		 * Private constructor to ensure the base class is initialized properly
		 * this method so be called from the extending class' constructor
		 * @private
		 */
		ctor: function (cfg)
		{
			AbstractView.superclass.constructor.apply(this, arguments);	
			
			cfg = cfg || {};
			Ext.apply(this, cfg);
			this.initialConfig = cfg;
		},
		
		/**
		 * @method init
		 */
		init: function (component)
		{
			this.component = component;
			
			component.on({
				'destroy': this.onDestroy,
				scope: this
			});
			
			this.initTemplates();
		},
		
		/**
		 * @method initTemplates
		 */
		initTemplates: Ext.emptyFn,
		
		/**
		 * @method render
		 */
		render: Ext.emptyFn,
		
		/**
		 * @method refresh
		 */
		refresh: Ext.emptyFn,
		
		/**
		 * Clean up references/event listeners
		 * @method onDestroy
		 * @private
		 */
		onDestroy: function ()
		{
			this.component.un('destroy', this.onDestroy, this);
		}		
	});
	
	net.autodata.AbstractView = AbstractView;	
})();